package spring.boot.initializer.impl;

import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import spring.boot.SpringApplication;
import spring.boot.initializer.MyWebApplicationInitializer;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @ClassName MyWebApplicationInitializer
 * @Description TODO
 * @Author Toolck Rin
 * @Date 2021/3/10 11:26
 * @Version 1.0
 **/

public class MyWebApplicationInitializerImpl implements MyWebApplicationInitializer {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        DispatcherServlet servlet = (DispatcherServlet) SpringApplication.registry.getBean("dispatcherServlet");
        ServletRegistration.Dynamic registration = servletContext.addServlet("app", servlet);
        registration.setLoadOnStartup(1);
        registration.addMapping("/");
    }
}
